package T500;

/**
 * @Author cheng.song
 * @create 2022/1/27 17:21
 */
public class 斐波那契数509 {

    public static void main(String[] args) {
        System.out.println(fib(4));
    }

    public static int fib(int n) {
        if(n<2)
            return n;
        int q =0,p=1,r=q+p;
        for (int i = 2; i < n; i++) {
            q=p;
            p=r;
            r=q+p;
        }
        return r;
    }

}
